import java.util.Stack;

/**
 * Created by loso on 2017/3/16.
 */
public class _232_ImplementQueueUsingStacks {



}

class MyQueue {

    private Stack<Integer> stackin;
    private Stack<Integer> stackout;

    /** Initialize your data structure here. */
    public MyQueue() {
        stackin = new Stack<>();
        stackout = new Stack<>();
    }

    /** Push element x to the back of queue. */
    public void push(int x) {
        stackin.push(x);
    }

    /** Removes the element from in front of queue and returns that element. */
    public int pop() {
        if (stackout.isEmpty()){
            while (!stackin.isEmpty()){
                stackout.push(stackin.pop());
            }
        }
        return stackout.pop();
    }

    /** Get the front element. */
    public int peek() {
        if (stackout.isEmpty()){
            while (!stackin.isEmpty()){
                stackout.push(stackin.pop());
            }
        }
        return stackout.peek();
    }

    /** Returns whether the queue is empty. */
    public boolean empty() {
        return stackin.isEmpty() && stackout.isEmpty();
    }
}